package com.boyon.common.log;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.After;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

import com.boyon.common.log.annotation.MethodFlag;

import lombok.extern.slf4j.Slf4j;

/**
 * ClassName:LogAspect <br/>
 * Function: 定义日志切面类. <br/>
 * Reason: ADD REASON. <br/>
 * Date: 2018年3月13日 上午12:07:34 <br/>
 * 
 * @author sunshulin
 * @version
 * @since JDK 1.8
 * @see
 */
@Aspect
@Component
@Slf4j
public class LogAspect {

	/**
	 * 
	 * logPoint:定义切面. <br/>
	 * 
	 * @author sunshulin
	 * @since JDK 1.8
	 */
	@Pointcut("@annotation(com.boyon.common.log.annotation.MethodFlag)")
	private void logPoint() {
		log.debug("定义标有com.boyon.common.log.annotation.MethodFlag注解切面");
	}

	/**
	 * 
	 * doAfter:定义后置通知. <br/>
	 * 
	 * @author sunshulin
	 * @since JDK 1.8
	 */
	@After(value = "logPoint() && @annotation(methodFlag)", argNames = "methodFlag")
	public void doAfter(JoinPoint jp, MethodFlag methodFlag) {
		log.debug("flag={}", methodFlag.key());
	}
}
